package com.core.service;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import com.core.dao.DAOException;
import com.core.dao.DAOFactory;
import com.core.entities.Country;

public class CountrySrv {
	private Connection conn;

	public CountrySrv(Connection conn) {
		this.conn = conn;
	}
	public List<String> getCountriesNames(){
		List<String> countriesNames = new ArrayList<String>();
		try{
			for(Country country : DAOFactory.getInstance().getCountryDAO(conn).selectAll())
				countriesNames.add(country.getName());
		}catch(DAOException e){
			e.printStackTrace();
		}
		return countriesNames;
	}
	
	public int getCountryPK(String countryName){
		try{
			return DAOFactory.getInstance().getCityDAO(conn).getByName(countryName).get(0).getId();
		}catch(DAOException e){
			e.printStackTrace();
		}
		return -1;
	}
	

}
